<template>
    <div class="sliderNav" :style="{ width: menuStore.isCollapse ? '64px' : '210px' }">
        <div class="logo">{{ menuStore.isCollapse ? '隧道' : '隧道管理系统' }}</div>
        <el-menu mode="vertical" background-color="#304156" text-color="#fff" active-text-color="#ffd04b"
            :default-active="active" router :collapse="menuStore.isCollapse" class="el-menu-vertical-demo">

            <template v-for="(item, index) in menuStore.menus" :key="index">
                <el-sub-menu v-if="item.children" :index="item.path">
                    <template #title>
                        <component :is="item.icon" class="icon"></component>
                        <span>{{ item.name }}</span>
                    </template>
                    <el-menu-item v-for="(childItem, childIndex) in item.children" :key="childIndex" :index="childItem.path">
                        <span>{{ childItem.name }}</span>
                    </el-menu-item>
                </el-sub-menu>

                <el-menu-item v-else :index="item.path">
                    <!-- <el-icon>
                        <House />
                    </el-icon> -->
                    <component :is="item.icon" class="icon"></component>
                    <span>{{ item.name }}</span>
                </el-menu-item>


            </template>

            <!-- <el-menu-item index="/"><el-icon><House /></el-icon><span>首页</span></el-menu-item>
            <el-menu-item index="/projectInfo"><el-icon><Message /></el-icon><span>项目基础信息</span></el-menu-item>
            <el-menu-item index="/tunnellInfo"><el-icon><Setting /></el-icon><span>隧道设计信息</span></el-menu-item>
            <el-menu-item index="/workManage"><el-icon><Filter /></el-icon><span>工作监督管理</span></el-menu-item>
            <el-menu-item index="/buildManage"><el-icon><Open /></el-icon><span>施工监控检测</span></el-menu-item>
            <el-menu-item index="/geologicslInfo"><el-icon><HelpFilled /></el-icon><span>超前地质预报</span></el-menu-item>
            <el-menu-item index="/systemManage"><el-icon><Histogram /></el-icon><span>系统信息管理</span></el-menu-item> -->
        </el-menu>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import { userMenuStore } from '../../stores/menuStore';

const active = ref("/");
const menuStore = userMenuStore();
// const isCollapse=ref(menuStore.isCollapse)

if (localStorage.getItem('active')) {
    active.value = localStorage.getItem('active')
}
</script>

<style scoped>
.sliderNav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 210px;
    background-color: #304156;
    transition: 0.3s ease-in;
}

.logo {
    width: 100%;
    height: 60px;
    background-color: #364e6d;
    text-align: center;
    font-size: 25px;
    color: #fff;
    line-height: 60px;
}

.icon {
    width: 16px;
    height: 16px;
    margin-right: 5px;
}
</style>